// Windows/Net.h

#ifndef __WINDOWS_NET_H
#define __WINDOWS_NET_H

namespace Common
{
namespace FileSystem
{
namespace Net {

struct CResourceBase
{
  DWORD Scope;
  DWORD Type;
  DWORD DisplayType;
  DWORD Usage;
  bool LocalNameIsDefined;
  bool RemoteNameIsDefined;
  bool CommentIsDefined;
  bool ProviderIsDefined;
};

struct CResource: public CResourceBase
{
  CString LocalName;
  CString RemoteName;
  CString Comment;
  CString Provider;
};

class CEnum
{
  HANDLE _handle;
  bool _handleAllocated;
  DWORD Open(DWORD scope, DWORD type, DWORD usage, LPNETRESOURCE netResource);
  DWORD Next(LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize);
protected:
  bool IsHandleAllocated() const { return _handleAllocated; }
public:
  CEnum(): _handleAllocated(false) {}
  ~CEnum() {  Close(); }
  DWORD Close();
  DWORD Open(DWORD scope, DWORD type, DWORD usage, const CResource *resource);
  DWORD Next(CResource &resource);
};

DWORD GetResourceParent(const CResource * const resource, CResource * const  parentResource);

DWORD GetResourceInformation(const CResource * const resource,
    CResource * const destResource, CString &systemPathPart);

DWORD AddConnection2(const CResource * const resource, LPCTSTR password, LPCTSTR userName, DWORD flags);

}}
}
#endif
